package com.valuegroup.smarttodo.data.vo;

import com.valuegroup.smarttodo.data.enums.GoalSortTypeEnum;
import com.valuegroup.smarttodo.data.model.AppStatus;
import com.valuegroup.smarttodo.plugins.pickdialog.DateUtils;

import java.io.Serializable;
import java.util.Date;

public class GoalQueryParams implements Serializable {

    // 查询范围
    private int range; // AppStatus.GoalsRange
    private int year;
    private int quarter;
    private int month;

    // 附加条件
    private boolean hideFinish;
    private boolean onlyStar;
    private boolean onlyFinish;
    private boolean onlyUnFinish;

    // 排序
    private GoalSortTypeEnum sortType;
    private boolean desc;

    public void readCfg(AppCustomCfg cfg) {
        setHideFinish(cfg.isGoalHideFinish());
        setDesc(cfg.isGoalSortDesc());
        setSortType(GoalSortTypeEnum.getSortTypeEnum(cfg.getGoalSortType()));
    }

    public static GoalQueryParams getDefaultParams() {
        GoalQueryParams p = new GoalQueryParams();
        Date today = new Date();

        p.setRange(AppStatus.GoalsRange.MONTHLY);
        p.setYear(DateUtils.getYear(today));
        p.setMonth(DateUtils.getMoth(today));
        p.setQuarter(DateUtils.getQuarter(today));
        p.setHideFinish(false);
        p.setOnlyStar(false);
        p.setOnlyFinish(false);
        p.setOnlyUnFinish(false);
        p.setSortType(GoalSortTypeEnum.NORMAL);
        p.setDesc(false);
        return p;
    }

    public int getRange() {
        return range;
    }

    public void setRange(int range) {
        this.range = range;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    public int getQuarter() {
        return quarter;
    }

    public void setQuarter(int quarter) {
        this.quarter = quarter;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public boolean isHideFinish() {
        return hideFinish;
    }

    public void setHideFinish(boolean hideFinish) {
        this.hideFinish = hideFinish;
    }

    public boolean isOnlyStar() {
        return onlyStar;
    }

    public void setOnlyStar(boolean onlyStar) {
        this.onlyStar = onlyStar;
    }

    public boolean isOnlyFinish() {
        return onlyFinish;
    }

    public void setOnlyFinish(boolean onlyFinish) {
        this.onlyFinish = onlyFinish;
    }

    public boolean isOnlyUnFinish() {
        return onlyUnFinish;
    }

    public void setOnlyUnFinish(boolean onlyUnFinish) {
        this.onlyUnFinish = onlyUnFinish;
    }

    public GoalSortTypeEnum getSortType() {
        return sortType;
    }

    public void setSortType(GoalSortTypeEnum sortType) {
        this.sortType = sortType;
    }

    public boolean isDesc() {
        return desc;
    }

    public void setDesc(boolean desc) {
        this.desc = desc;
    }
}
